1. Field of the Invention
Embodiments of the present invention relate generally to context switching and, more particularly, to a method and a system for signaling a context switch to a processing engine.
2. Description of the Related Art
A context switch is a feature of a multitasking operating system that allows for a switch in execution from one computing thread or process to another. This feature ensures that a processor cannot be monopolized by any one processor-intensive thread or process. During a context switch, the states of the processor of the currently running process are stored in memory and the processor is restored with states of another process that was previously stored in memory.
In graphics applications, a number of threads may be mutiprocessed through each of the different graphics engines that are part of a graphics processing unit (GPU).
FIG. 1 is a simplified block diagram of a computer system 100 that includes a GPU 120 that includes a host unit 122 and a plurality of processing engines 124-1, 124-2, 124-3, which may be, for example, a graphics engine, a video processing engine, and a display engine, respectively. The processing engines 124 have access to a local graphics memory 130 through a memory interface 126. The GPU 120 and the local graphics memory 130 represent a graphics subsystem that is accessed by a central processing unit (CPU) 110 of the computer system 100 using a driver that is stored in a system memory 112.
The host unit 122 is responsible for distributing methods to the processing engines 124. Each of the processing engines 124 places the stream of methods that it receives from the host unit 122 in a FIFO memory and processes the methods one after another through a processing pipeline. The host unit 122 is also responsible for scheduling the different threads through the processing engines 124 and for signaling the processing engines 124 to perform a context switch in accordance with that schedule.
To enable the context switching functionality, the processing engines of conventional computer systems are configured to broadcast to the host unit the context that they are currently working on. When the host unit desires to perform a context switch in a processing engine and determines that the context broadcast by that processing engine is different from the context that the host unit wants the processing engine to work on, the host unit places a context switch request in the method stream for that processing engine.
The processing engine, however, typically does not perform the context switch requested by the host unit immediately, because the processing engine cannot act on the context switch request until all other methods that are ahead of the context switch request in the method stream and stored in the FIFO memory, are moved out of the FIFO memory and sent down the processing pipeline. As a result, context switches carried out in the above manner are subject to highly variable delays. The host unit may be configured to keep track of such variable delays so that a more precise scheduling of context switches can be achieved, but such a technique is not desirable because it adds too much overhead to the host unit.